<template>
	<view class="my" v-if="user">
		<view class="topBox">
			<view class="userInfoBox flex_space_b" @tap="goSystem">
				<view class="userInfo flex_conter">
					<image class="avatar" :src="user.user_headimg" mode="aspectFill"></image>
					<view class="info">
						<view class="uname">{{user.user_nickname}}</view>
						<view class="status">
							<text>查看资料</text>
						</view>
					</view>
				</view>
				<view class="iconBox">
					<u-icon name="arrow-right" color="#fff" size="32"></u-icon>
				</view>
			</view>
			<view class="balance mTop2">
				<view>
					<view>账户余额</view>
					<view class="value">
						<text>￥</text>
						<text class="num">6.85</text>
					</view>
				</view>
			</view>
		</view>
		
		<view class="contentBox">
			<view class="card">
				<view class="cardCon flex_space_b">
					<view class="item" @click="goUrl('/pages/my/balance')">
						<text class="custom-icon custom-icon-jifeimingxi"></text>
						<view class="label">余额明细</view>
					</view>
					<view class="item" @click="goUrl('/pages/my/withdraw')">
						<text class="custom-icon custom-icon-balance"></text>
						<view class="label">余额提现</view>
					</view>
					<view class="item" @click="goUrl(`/pagesB/my/income`)">
						<text class="custom-icon custom-icon-shouyi1"></text>
						<view class="label">收益</view>
					</view>
					<view class="item" @click="goUrl('/pagesB/my/team')">
						<text class="custom-icon custom-icon-tuandui1"></text>
						<view class="label">团队</view>
					</view>
				</view>
			</view>
			
			<view class="card mTop2">
				<view class="title">
					<view class="left">我的订单</view>
					<view class="right" @click="goOrder(0)">查看全部订单<u-icon name="arrow-right" color="#999" size="24"></u-icon></view>
				</view>
				
				<view class="cardCon flex_space_b">
					<view class="item" @click="goOrder(0)">
						<text class="custom-icon custom-icon-chengtuan"></text>
						<view class="label">成团中</view>
					</view>
					<view class="item" @click="goOrder(3)">
						<text class="custom-icon custom-icon-daifahuo"></text>
						<view class="label">待发货</view>
					</view>
					<view class="item" @click="goOrder(4)">
						<text class="custom-icon custom-icon-daishouhuofuben"></text>
						<view class="label">待收货</view>
					</view>
					<view class="item" @click="goOrder(5)">
						<text class="custom-icon custom-icon-yiwancheng"></text>
						<view class="label">已完成</view>
					</view>
				</view>
			</view>
			
			<view class="funBox mTop2">
				<view class="item" @click="goUrl(`/pagesB/my/address`)">
					<u-icon class="icon" name="tubiao" custom-prefix="custom-icon" size="48" color="#333"></u-icon>
					<view class="label">地址</view>
				</view>
				<view class="item" @click="goUrl(`/pagesB/my/collect`)">
					<u-icon class="icon" name="shoucang" custom-prefix="custom-icon" size="48" color="#333"></u-icon>
					<view class="label">收藏</view>
				</view>
				<view class="item" @click="goUrl(`/pages/my/footprint`)">
					<u-icon class="icon" name="zuji1" custom-prefix="custom-icon" size="48" color="#333"></u-icon>
					<view class="label">足迹</view>
				</view>
				<view class="item" @click="share">
					<u-icon class="icon" name="fenxiang" custom-prefix="custom-icon" size="48" color="#333"></u-icon>
					<view class="label">分享</view>
				</view>
				<view class="item" @click="goUrl(`/pagesB/my/parse?type=hezuo`)">
					<u-icon class="icon" name="shangwuhezuo" custom-prefix="custom-icon" size="48" color="#333"></u-icon>
					<view class="label">商务合作</view>
				</view>
				<view class="item" @click="goUrl(`/pagesB/my/parse?type=guize`)">
					<u-icon class="icon" name="guizeguanli" custom-prefix="custom-icon" size="48" color="#333"></u-icon>
					<view class="label">交易规则</view>
				</view>
				<view class="item" @click="goUrl(`/pagesB/my/parse?type=wenti`)">
					<u-icon class="icon" name="changjianwenti" custom-prefix="custom-icon" size="48" color="#333"></u-icon>
					<view class="label">常见问题</view>
				</view>
				<button class="item service_btn" open-type="contact" @bindcontact="handleContact" v-if="use_scene == 'mp-weixin'">
					<u-icon class="icon" name="kefu" custom-prefix="custom-icon" size="48" color="#333"></u-icon>
					<view class="label">客服</view>
				</button>
				<!-- <view class="item" @click="goUrl(`/pagesB/my/coupon`)">
					<u-icon class="icon" name="qiaquan" custom-prefix="custom-icon" size="48" color="#333"></u-icon>
					<view class="label">优惠券</view>
				</view> -->
				<!-- <view class="item" @click="goUrl(`/pagesB/my/redEnvelope`)">
					<u-icon class="icon" name="hongbao" custom-prefix="custom-icon" size="48" color="#333"></u-icon>
					<view class="label">红包</view>
				</view>
				<view v-if="new_user_hongbao_id > 0" class="item" @click="go_hongbao_new">
					<u-icon class="icon" name="hongbao" custom-prefix="custom-icon" size="48" color="#333"></u-icon>
					<view class="label">红包分享</view>
				</view>
				<view class="item" @click="goUrl(`/pagesB/my/lottery`)">
					<u-icon class="icon" name="choujiang" custom-prefix="custom-icon" size="48" color="#333"></u-icon>
					<view class="label">积分抽奖</view>
				</view> -->

				<!-- <view class="item" @click="goUrl(`/pagesB/my/liveShopping`)">
					<u-icon class="icon" name="airudiantubiaohuizhi-zhuanqu_zhibojian" custom-prefix="custom-icon" size="48" color="#333"></u-icon>
					<view class="label">直播购物</view>
				</view>
				<view class="item" @click="goUrl(`/pagesB/my/live/myLive`)">
					<u-icon class="icon" name="zhibo" custom-prefix="custom-icon" size="48" color="#333"></u-icon>
					<view class="label">我的直播</view>
				</view> -->
				
				<!-- <view class="item" @click="QRshow = true">
					<u-icon class="icon" name="kefu" custom-prefix="custom-icon" size="48" color="#333"></u-icon>
					<view class="label">客服</view>
				</view> -->
				<!-- <view class="item" @click="goUrl(`/pagesB/my/help`)">
					<u-icon class="icon" name="bangzhu" custom-prefix="custom-icon" size="48" color="#333"></u-icon>
					<view class="label">帮助</view>
				</view> -->
				<!-- <view class="item" @click="goUrl(`/pagesB/my/parse?type=about`)">
					<u-icon class="icon" name="guanyuwomen" custom-prefix="custom-icon" size="48" color="#333"></u-icon>
					<view class="label">关于</view>
				</view> -->
				<view class="item" @click="goUrl(`/pages/my/download`)" v-if="use_scene != 'app' && use_scene != 'mp-weixin'">
					<image class="image" src="/static/logo.png" mode="aspectFill"></image>
					<view class="label">下载app</view>
				</view>
				<view class="item" @click="goUrl(`/pages/my/setting`)" v-if="use_scene != 'mp-weixin'">
					<u-icon class="icon" name="setting" size="48" color="#333"></u-icon>
					<view class="label">设置</view>
				</view>
			</view>
		</view>
		
		<u-popup v-model="QRshow" mode="center" border-radius="12">
			<view class="popupBox" @click="previewImage">
				<u-image width="300rpx" height="300rpx" :src="service_wechat"></u-image>
				<view class="label">点击预览后，保存图片</view>
			</view>
		</u-popup>
		
		<view class="winningMask_hongbao winningShow_hongbao" v-if="is_user_hongbao>0">
			<view class="winning_hongbao">
				<image class="winningImage_hongbao" mode="widthFix" src="/static/winning.png"></image>
				<view class="con mTop3">
					<view class="winningName redText mTop4">
						<view>{{user_hongbao_text}}</view>
					</view>
				</view>
				<button class="btn mTop3" type="default" @click="go_hongbao">去分享</button>
				<view class="iconBox">
					<text class="custom-icon custom-icon-chahao" @click="is_user_hongbao=0"></text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	var util = require('../../common/util.js');
	export default {
		data() {
			return {
				QRshow: false,
				service_wechat:"",
				user:null,
				loading_count:0,
				use_scene:util.getCurrentSecene(),
				is_user_hongbao:0,
				user_hongbao_text:'',
				new_user_hongbao_id:0
			}
		},
		onLoad() {
			// util.is_wechat_xcx_auth();
		},
		onShow() {
			if(util.is_wechat_xcx_auth()){
				let is_loading = false;
				if(this.loading_count == 0){
					is_loading = true;
				}
				this.loading_count ++;
				this.loadData(is_loading);
				this.checkIsUserHongbao();
			}
		},
		methods: {
			checkIsUserHongbao:function(){
				var that = this;
				util.requestPost("api.php/Hongbao/checkUserHongbao", {}, function(res) {
					that.is_user_hongbao = res.data.is_user_hongbao;
					that.user_hongbao_text = res.data.user_hongbao_text;
				},false);
			},
			go_hongbao(){
				//红包
				uni.navigateTo({
					url: '/pagesB/my/shareRedEnvelope?id='+this.is_user_hongbao
				})
			},
			go_hongbao_new(){
				uni.navigateTo({
					url: '/pagesB/my/shareRedEnvelope?id='+this.new_user_hongbao_id
				})
			},
			loadData: function(is_loading){
				// 加载数据
				var that = this;
				util.requestPost("api.php/user/index", {}, function(res) {
					that.service_wechat = res.data.service_wechat;
					that.user = res.data.user;
					that.new_user_hongbao_id = res.data.new_user_hongbao_id;
				},is_loading);
			},
			goOrder (id) {
				uni.setStorageSync('orderTab', id);
				
				uni.switchTab({
					url: '/pages/order/order'
				})
			},
			goUrl (url) {
				uni.navigateTo({
					url
				})
			},
			goSystem () {
				uni.navigateTo({
					url: '/pages/my/system'
				})
			},
			previewImage () {
				uni.previewImage({
					urls: [this.service_wechat]
				});
			},
			share(){
				// util.toast("请移步首页分享！");
				uni.navigateTo({
					url:`/pagesB/my/share`
				})
			},
			handleContact (e) {
				console.log(e.detail.path)
				console.log(e.detail.query)
			}
		}
	}
</script>

<style scoped>
.my {
	min-height: 100%;
	background-color: var(--bgColor);
	/*  #ifdef  H5  */
	padding-bottom: 60px;
	/*  #endif  */
}
	
.topBox {
	position: relative;
	padding: 40rpx 30rpx;
	align-items: stretch;
	background: linear-gradient(90deg, #22ac38, #48b520);;
}
.topBox .userInfoBox {
	position: relative;
	z-index: 4;
}
.userInfo .avatar {
	width: 100rpx;
	height: 100rpx;
	border-radius: 100rpx;
	border: 2rpx solid #FFFFFF;
}
.userInfo .info {
	margin-left: 20rpx;
}
.userInfo .info .uname {
	color: #FFFFFF;
	font-weight: 600;
	font-size: 34rpx;
}
.userInfo .info .status {
	margin-top: 12rpx;
	background-color: rgba(0, 0, 0, 0.3);
	border-radius: 30rpx;
	padding: 4rpx 20rpx 6rpx;
	font-size: 24rpx;
	color: #FFFFFF;
	width: fit-content;
}
.userInfo .info .status .vip {
	color: #dfb700;
}
.topBox .balance {
	display: flex;
	justify-content: flex-end;
	color: #FFFFFF;
	font-size: 34rpx;
	text-align: center;
	padding-right: 52rpx;
}
.topBox .balance .num {
	font-size: 42rpx;
}

.topBox .cardBox {
	position: absolute;
	top: 200rpx;
	left: 50%;
	z-index: 5;
	width: 690rpx;
	transform: translateX(-50%);
	background-color: #FFFFFF;
	border-radius: 12rpx;
	padding: 24rpx 0;
	box-shadow: 0 0 8rpx rgba(0, 0, 0, 0.2);
}
.topBox .cardBox .item {
	flex: 1;
	text-align: center;
	font-size: 24rpx;
}
.topBox .cardBox .item .number {
    margin-bottom: 4rpx;
}
.topBox .cardBox .item .number text {
	font-size: 36rpx;
}
.topBox .cardBox .item .label {
	color: #999999;
}

.contentBox {
	padding: 30rpx;
	/* margin-top: 100rpx; */
}
.card {
	background-color: #FFFFFF;
	border-radius: 12rpx;
}
.card .title {
	font-size: 28rpx;
	font-weight: 600;
	padding: 20rpx;
	border-bottom: 1rpx solid #EEEEEE;
	overflow: hidden;
}
.card .title .left {
	float: left;
}
.card .title .right {
	float: right;
	font-size: 24rpx;
	font-weight: 500;
	color: #999999;
}
.card .cardCon .titleBox {
	width: 140rpx;
	text-align: center;
	position: relative;
	padding: 40rpx 12rpx 40rpx 0;
}
.card .cardCon .titleBox .text {
	margin-top: 4rpx;
	font-size: 28rpx;
	font-weight: 600;
}
.card .cardCon .titleBox .lineImage {
	position: absolute;
	right: 12rpx;
	top: 50%;
	transform: translateY(-50%);
	width: 12rpx;
}
.card .cardCon .item {
	flex: 1;
	text-align: center;
	padding: 40rpx 0;
	position: relative;
}
.card .cardCon .item .badge {
	position: absolute;
	top: 16rpx;
	left: 50%;
	color: #FFFFFF;
	font-size: 18rpx;
	background-color: var(--primaryColor);
	border-radius: 40rpx 40rpx 40rpx 0;
	padding: 0 8rpx;
}
.card .cardCon .item .number {
	font-size: 36rpx;
	font-weight: bold;
	margin-bottom: 4rpx;
}
.card .cardCon .item .number text {
	font-size: 24rpx;
}
.card .cardCon .item .image {
	width: 52rpx;
	height: 52rpx;
	margin-bottom: 6rpx;
}
.card .cardCon .item .label {
	color: #333333;
	font-size: 24rpx;
	margin-top: 8rpx;
}
.card .cardCon .item .label .icon {
	margin-right: 4rpx;
}
.card .cardCon .item .custom-icon {
	font-size: 52rpx;
	margin-bottom: 6rpx;
	color: var(--primaryColor);
}

.funBox {
	background-color: #FFFFFF;
	border-radius: 12rpx;
	display: flex;
	flex-wrap: wrap;
}
.funBox .item {
	width: 25%;
	text-align: center;
	padding: 20rpx 0;
	line-height: inherit;
}
.funBox .item .icon {
	margin-bottom: 6rpx;
}
.funBox .item .image {
	width: 50rpx;
	height: 50rpx;
	margin-bottom: 6rpx;
}
.funBox .item .label {
	color: #333333;
	font-size: 24rpx;
	margin-top: 8rpx;
}

.popupBox {
	padding: 32rpx;
}
.popupBox .label {
	text-align: center;
	color: #666666;
}
.service_btn {
	margin: 0;
	padding: 20rpx 0 !important;
	background: none;
	border: none;
	outline: none;
}
.service_btn::after {
  border: none;
}
</style>
